package com.gitee.attendance;

import com.gitee.attendance.service.MessageQueueServiceI;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(1)
public class MyApplicationRunner implements ApplicationRunner {

    private Logger logger = LoggerFactory.getLogger(MyApplicationRunner.class);

    @Value("${baidu.QPS:2}")  
    private int qps;

    @Value("${server.run.module}")  
    private String serverRunModule;

    @Autowired
    private MessageQueueServiceI messageQueueService;

    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {



        logger.info("-------------->" + "项目启动完毕");

        if(serverRunModule.contains("2")){
            for(int i = 0;i < qps ;i++ ){
                Thread attendance = new Thread() {
                    public void run() {
                        try {
                            messageQueueService.attendanceb();
                        } catch (Exception e) {
                            logger.error(e.toString());
                        }
                    }
                };
    
                attendance.start();
                logger.info("考勤信息处理"+i+"-------------->" + "启动完毕");
            }

        }

    }

}